/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Control;
import Model.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author Radu
 */
public class CtrCustomer {
    public CtrCustomer() {

    }
    public ArrayList findAllCustomers()
    {
      DbInterfaceCustomer dbCust = new DbCustomer();
      ArrayList allCust = new ArrayList();
      allCust = dbCust.getAllCustomers("");
      return allCust;
    }
    public Customer findByName(String name)
    {
        DbInterfaceCustomer dbCust = new DbCustomer();
        return dbCust.getByName(name);
    }

	public Customer findById(String id) {
		DbInterfaceCustomer dbCust = new DbCustomer();
		return dbCust.getCustomerById(id);
	}
	public Customer findByEmail(String email) {
		DbInterfaceCustomer dbCust = new DbCustomer();
		return dbCust.getCustomerByEmail(email);
	}
	public Customer findByPhone(String phone) {
		DbInterfaceCustomer dbCust = new DbCustomer();
		return dbCust.getCustomerByPhone(phone);
	}

      public Customer getCustomerById(String id)
    {
        DbInterfaceCustomer dbCust = new DbCustomer();
        return dbCust.getCustomerById(id);
    }
      public void updateCustomer(String name, String address, String zip, String phone, String email, Double discount)
      {
          DbInterfaceCustomer dbCust = new DbCustomer();
          Customer cust = new Customer();
          cust.setName(name);
          cust.setAddress(address);
          cust.setZip(zip);
          cust.setPhone(phone);
          cust.setEmail(email);
          cust.setDiscount(discount);
          dbCust.updateCustomer(cust);
      }

      public void insertNew(Customer custObj)
      {
           DbInterfaceCustomer dbCust = new DbCustomer();
           dbCust.insertCustomer(custObj);
      }

      public void deleteCustomer(String phone){
          DbInterfaceCustomer dbCust = new DbCustomer();
          dbCust.deleteCustomer(phone);
      }

}
